﻿Public Class MemorizedItem
  Implements AvianWaves.AvianPlay.Library.Plugin.iLibraryItem

  Private Shared hash As Integer = Integer.MinValue

  Private _key As Integer
  Private _artist As String = String.Empty
  Private _title As String = String.Empty
  Private _date As String = String.Empty
  Private _station As String = String.Empty


  Public Sub New()
    Me._key = hash
    hash += 1
  End Sub

  Public Property AVPLRef() As AvianWaves.AvianPlay.Playlists.AVPLPlaylistEntry Implements AvianWaves.AvianPlay.Library.Plugin.iLibraryItem.AVPLRef
    Get
      Return Nothing ' This plugin never has AVPL Entries
    End Get
    Set(ByVal value As AvianWaves.AvianPlay.Playlists.AVPLPlaylistEntry)
    End Set
  End Property

  Public Property Icon() As System.Drawing.Bitmap Implements AvianWaves.AvianPlay.Library.Plugin.iLibraryItem.Icon
    Get
      Return Nothing ' No icons for any items
    End Get
    Set(ByVal value As System.Drawing.Bitmap)
    End Set
  End Property

  Public Property Key() As String Implements AvianWaves.AvianPlay.Library.Plugin.iLibraryItem.Key
    Get
      Return Me._key.ToString
    End Get
    Set(ByVal value As String)
      Try
        Me._key = Integer.Parse(value)
      Catch
        ' Don't change the key if it can't be parsed
      End Try
    End Set
  End Property

  Public Property Text() As String Implements AvianWaves.AvianPlay.Library.Plugin.iLibraryItem.Text
    Get
      Return Me._title
    End Get
    Set(ByVal value As String)
    End Set
  End Property

  Public Property Subtext() As String Implements AvianWaves.AvianPlay.Library.Plugin.iLibraryItem.Subtext
    Get
      If Me._artist.Length > 0 AndAlso Me._date.Length > 0 Then
        Return Me._artist & " - " & Me._date
      ElseIf Me._artist.Length > 0 Then
        Return Me._artist
      ElseIf Me._date.Length > 0 Then
        Return Me._date
      Else
        Return String.Empty
      End If
    End Get
    Set(ByVal value As String)
    End Set
  End Property

  Public Property Artist() As String
    Get
      Return Me._artist
    End Get
    Set(ByVal value As String)
      Me._artist = value
    End Set
  End Property

  Public Property Title() As String
    Get
      Return Me._title
    End Get
    Set(ByVal value As String)
      Me._title = value
    End Set
  End Property

  Public Property [Date]() As String
    Get
      Return Me._date
    End Get
    Set(ByVal value As String)
      Me._date = value
    End Set
  End Property

  Public Property Station() As String
    Get
      Return Me._station
    End Get
    Set(ByVal value As String)
      Me._station = value
    End Set
  End Property

  Public ReadOnly Property HasData() As Boolean
    Get
      If Me._artist.Length > 0 OrElse Me._title.Length > 0 Then
        Return True
      Else
        Return False
      End If
    End Get
  End Property

  Public Overrides Function GetHashCode() As Integer
    Return Me._key
  End Function
End Class
